package com.diandian.pos.rabbitmq;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by jakehu on 2015/10/16.
 */
@Component
public class RmqPull {
    private Logger logger= LoggerFactory.getLogger(RmqPull.class);

    @Autowired
    private AmqpTemplate amqpTemplate;

    public String pull(){
        String message = (String)amqpTemplate.receiveAndConvert("ddpos");
        //AmqpItemReader<String> amqpItemReader = new AmqpItemReader<String>(amqpTemplate);

        if (!StringUtils.isBlank(message))
            logger.info("get message is {}",message);
        else{
            logger.info("get message is null");
        }
        return message;
    }

}
